package main

import (
	"fmt"

	"gitee.com/go-course/go9/tree/master/projects/vblog/api/apps/user/api"
	"gitee.com/go-course/go9/tree/master/projects/vblog/api/apps/user/impl"
	"gitee.com/go-course/go9/tree/master/projects/vblog/api/conf"
	"github.com/gin-gonic/gin"
)

// 项目执行入口, 组装程序的实例类, 让他们以一个服务的方式跑起来
func main() {
	// 加载程序配置
	conf.LoadConfigFromToml("etc/config.toml")

	// 加载实例类
	userSvc := impl.NewImpl()

	// http API handler
	userAPI := api.NewHandler(userSvc)

	// 需要注册给Gin Root router
	server := gin.Default()
	v1 := server.Group("/vblog/api/v1")
	userAPI.Registry(v1)

	// 启动HTTP接口监听
	if err := server.Run(":8050"); err != nil {
		fmt.Println(err)
	}
}
